﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace _555Calc
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void calcButton_Click(object sender, EventArgs e)
        {
            if (r1Text.TextLength < 1 || r2Text.TextLength < 1 || c1Text.TextLength < 1)
            {
                MessageBox.Show("There must be valid values in R1, R2, and C1");
                return;   
            }
            String r1s = r1Text.Text; double r1 = Convert.ToDouble(r1s);
            String r2s = r2Text.Text; double r2 = Convert.ToDouble(r2s);
            String c1s = c1Text.Text; double c1 = Convert.ToDouble(c1s);

            double tlow = 0.693 * r2 * c1; tlow = tlow / 1000000;
            double thigh = 0.693 * (r1 + r2) * c1; thigh = thigh / 1000000;
            double freq = 1.44/((r1 + 2*r2) * c1);
            double duty = thigh/(tlow + thigh);

            tlowLabel.Text = tlow.ToString() + " ms";
            thighLabel.Text = thigh.ToString() + " ms";
            freqLabel.Text = freq.ToString() + " Hz";
            dutyLabel.Text = duty.ToString();

        }

        private void formulaButton_Click(object sender, EventArgs e)
        {
            Formula dlg = new Formula();
            dlg.ShowDialog();
        }

        private void clickLink(object sender, LinkLabelLinkClickedEventArgs e)
        {
            WebBrowser wb = new WebBrowser();
            wb.Navigate("http://www.boldscientist.com",true);
        }

    }
}
